1 00:00:00,640 --> 00:00:06,550 In this lecture, I wanted to show you another cool instance in Roblox that allows us to add realistic 2 00:00:06,550 --> 00:00:08,650 clouds into our games. 3 00:00:08,650 --> 00:00:13,630 This kind of instance can be very crucial for those of you who would like to create a dynamic weather 4 00:00:13,630 --> 00:00:19,420 system, and being able to manipulate the clouds in your game can add another layer of immersion. 5 00:00:19,420 --> 00:00:25,810 So to add clouds into the atmosphere of our game, we can go ahead and create a new cloud instance and 6 00:00:25,810 --> 00:00:28,210 make it a child of the terrain. 7 00:00:28,210 --> 00:00:31,660 So let's go ahead and add a new clouds instance inside of here. 8 00:00:31,660 --> 00:00:36,340 And as you can already see, we've got a few clouds set into the atmosphere. 9 00:00:36,340 --> 00:00:42,370 And we only have three properties to manipulate inside of the cloud, which is how much coverage the 10 00:00:42,370 --> 00:00:48,370 cloud should cover the sky with the density of the cloud, and then the color of the cloud. 11 00:00:48,580 --> 00:00:54,910 So the cover simply defines the percentage of sky that should be covered by clouds in your game. 12 00:00:54,910 --> 00:01:02,350 For example, if you set it to a value of one now your entire sky is going to be covered with those 13 00:01:02,350 --> 00:01:02,890 clouds. 14 00:01:02,890 --> 00:01:08,170 And if you set it to zero, you're going to have no coverage of clouds inside of your game. 15 00:01:08,750 --> 00:01:10,940 I'm going to set it to 0.5 for now. 16 00:01:10,940 --> 00:01:16,790 And if you take a real close look at the clouds, you should be able to notice that they're slightly 17 00:01:16,790 --> 00:01:17,540 moving. 18 00:01:17,540 --> 00:01:23,510 There's a little bit of moving effects to your cloud because again, it has just a little bit more immersion. 19 00:01:23,510 --> 00:01:26,420 You can just kind of see them slowly moving around. 20 00:01:26,600 --> 00:01:31,790 Now the density is going to define the intensity of the particles that make up your clouds. 21 00:01:31,790 --> 00:01:36,830 And this basically just controls the transparency of your clouds, where a small density value is going 22 00:01:36,830 --> 00:01:44,330 to result in thin and wispy looking clouds, while a high value is going to result in thicker and darker 23 00:01:44,330 --> 00:01:46,400 kind of stormy looking clouds. 24 00:01:46,400 --> 00:01:54,470 So with this half sky coverage, if I set the density to something like, let's say I were to set it 25 00:01:54,470 --> 00:01:55,820 to 0.1. 26 00:01:56,300 --> 00:01:58,190 As you can see, we barely can't see any clouds. 27 00:01:58,190 --> 00:02:00,560 There's very few clouds in our game. 28 00:02:00,560 --> 00:02:02,150 They're very thin, very wispy. 29 00:02:02,150 --> 00:02:08,930 And even if I max up the coverage to one and I keep the density at 0.1, as you can see, these clouds 30 00:02:08,930 --> 00:02:11,840 are very thin and we can still see the sun coming through it. 31 00:02:11,840 --> 00:02:17,960 And of course, I can decrease this value even more, and even more so if I set it to a value that's 32 00:02:17,960 --> 00:02:18,650 a little bit. 33 00:02:19,340 --> 00:02:25,550 Two small of a value, but you can still see a very thin layer of clouds in our atmosphere. 34 00:02:25,550 --> 00:02:26,930 So let me try that again. 35 00:02:27,660 --> 00:02:28,380 There we go. 36 00:02:28,410 --> 00:02:33,390 There is a very thin but a complete coverage of clouds over our game. 37 00:02:33,390 --> 00:02:37,500 And of course, the last property here we have is to manipulate the color of the cloud. 38 00:02:37,500 --> 00:02:41,790 So if you want darker clouds, you can of course make it a darker color. 39 00:02:41,790 --> 00:02:47,130 If you want multicolored clouds for some reason, you can change the color of your clouds as well. 40 00:02:47,250 --> 00:02:52,620 And this color property is also going to be influenced by any of the lighting properties that you have 41 00:02:52,620 --> 00:02:53,340 in your game. 42 00:02:53,340 --> 00:02:58,230 So you always want to make sure that you kind of experiment a bit with the lighting properties and the 43 00:02:58,230 --> 00:03:02,430 color of your clouds, just to make it look the best for whatever your game is going to be. 44 00:03:03,190 --> 00:03:09,070 And we are also able to manipulate the speed and the direction of movement for these clouds. 45 00:03:09,070 --> 00:03:13,360 So let me go ahead and increase the density to let's say 0.75. 46 00:03:13,360 --> 00:03:17,080 And we're going to reduce the coverage to 0.6. 47 00:03:17,500 --> 00:03:19,960 So now we have some nice cloud coverage going on. 48 00:03:19,960 --> 00:03:26,200 Now if I want to be able to manipulate the movement of these clouds, then I can go ahead and go to 49 00:03:26,200 --> 00:03:30,730 my workspace and we can go ahead and change the global wind property. 50 00:03:30,730 --> 00:03:36,580 So for example, let's go ahead and have my clouds blow in the X direction. 51 00:03:36,580 --> 00:03:40,180 And actually we can press these three dots right here to open up this menu. 52 00:03:41,050 --> 00:03:43,810 And let's go ahead and increase the speed. 53 00:03:43,840 --> 00:03:45,880 Let me go ahead and move this of the wind. 54 00:03:45,880 --> 00:03:52,180 So if I increase this and increase this, as you can see now our clouds are moving across the sky. 55 00:03:52,180 --> 00:03:54,880 And if I make it extremely fast. 56 00:03:54,880 --> 00:03:58,180 So as you can see, all of our clouds are moving in this particular direction. 57 00:03:58,180 --> 00:04:04,900 But of course I think I'm able to change the yeah, we can change the yaw or I believe this is the pitch. 58 00:04:04,900 --> 00:04:08,110 So right now we're changing the pitch of the wind. 59 00:04:08,820 --> 00:04:11,070 We can change the yaw of the wind. 60 00:04:11,070 --> 00:04:15,600 So this manipulates what direction the clouds are going to be blowing towards. 61 00:04:15,600 --> 00:04:17,460 So now they're moving in that direction. 62 00:04:17,460 --> 00:04:20,280 And if I shift it around now, they're blowing in that direction. 63 00:04:20,280 --> 00:04:22,830 Or if I shift it this way, they're blowing in that direction. 64 00:04:22,830 --> 00:04:24,000 Very cool looking. 65 00:04:25,270 --> 00:04:27,880 Let me go ahead and reset this back to zero. 66 00:04:28,000 --> 00:04:34,750 And let's go ahead and use the tween service to manipulate these clouds in the game from the client 67 00:04:34,750 --> 00:04:35,140 side. 68 00:04:35,140 --> 00:04:38,710 So I'm going to set the cover and density to zero. 69 00:04:38,710 --> 00:04:42,730 And then I'm going to create a local script in starter player scripts. 70 00:04:43,000 --> 00:04:45,730 We're going to go ahead and grab the tween service. 71 00:04:48,370 --> 00:04:53,020 And then we'll make a reference to our clouds instance, which is going to be in the workspace terrain 72 00:04:53,020 --> 00:04:54,340 dot clouds. 73 00:04:55,560 --> 00:05:00,780 Now, if you have streaming enabled in your workspace, you're probably going to have to use wait for 74 00:05:00,780 --> 00:05:02,640 child to access the cloud instance. 75 00:05:02,640 --> 00:05:05,970 But I'm going to disable streaming enabled so I don't have to do that. 76 00:05:07,140 --> 00:05:12,450 And now what I'm going to do is use the tween service create on this cloud instance. 77 00:05:12,450 --> 00:05:17,130 And we want to go ahead and manipulate the density and the coverage property for our clouds. 78 00:05:17,130 --> 00:05:21,060 So we'll do a tween info dot new of let's say five seconds. 79 00:05:21,360 --> 00:05:27,990 And maybe we want to transition from zero coverage and zero density to complete coverage and full density. 80 00:05:28,590 --> 00:05:30,690 So we can go ahead and set the goal table. 81 00:05:30,690 --> 00:05:32,220 The cover is going to be one. 82 00:05:32,370 --> 00:05:34,800 And then the density is also going to be one. 83 00:05:35,410 --> 00:05:38,080 And then we can go ahead and play this tween on the client. 84 00:05:38,080 --> 00:05:41,890 We'll put a small yield here to allow my player to load into the game. 85 00:05:42,070 --> 00:05:47,050 But if you wanted to create a weather system, what you could do is you could have the server pick what 86 00:05:47,050 --> 00:05:52,540 weather is supposed to happen, and then it could set a value and replicated storage to communicate 87 00:05:52,540 --> 00:05:55,150 to all the players in the game, hey, change it to this weather. 88 00:05:55,150 --> 00:06:00,970 Or you could use a remote event and then the clients would execute code on their copy of the game to 89 00:06:00,970 --> 00:06:03,520 manipulate, for example, the clouds. 90 00:06:03,520 --> 00:06:08,710 So let's say it's a sunny day, and then all of a sudden the server decides, hey, you know, it should 91 00:06:08,710 --> 00:06:09,490 be stormy. 92 00:06:09,490 --> 00:06:15,580 So then the client's like, okay, let me go ahead and boom, put in some cloud coverage, and now you've 93 00:06:15,580 --> 00:06:18,130 got stormy clouds covering your game. 94 00:06:18,130 --> 00:06:23,170 You could also manipulate the brightness in your game and the color of the clouds to make them more 95 00:06:23,170 --> 00:06:23,920 dark. 96 00:06:23,920 --> 00:06:29,800 And then afterwards you could figure out how to make some rain effects with particle emitters coming 97 00:06:29,800 --> 00:06:31,810 on your camera, all that kind of good stuff. 98 00:06:32,320 --> 00:06:36,340 But as you can see, it's very easy to manipulate the clouds using the tween service. 99 00:06:36,340 --> 00:06:41,170 If we want a slower transition, of course we can change this value to maybe something like 15 seconds. 100 00:06:41,170 --> 00:06:47,140 So now if we play in our game, we're going to have a slower transition of these clouds coming in to 101 00:06:47,140 --> 00:06:48,760 cover the sky. 102 00:06:48,760 --> 00:06:49,720 So there we go. 103 00:06:49,720 --> 00:06:55,300 Here's our clouds slowly transitioning in and then boom blocks out the sky. 104 00:06:55,300 --> 00:06:56,200 Complete coverage. 105 00:06:56,200 --> 00:06:58,990 And now we've got a very dark looking atmosphere. 106 00:07:00,800 --> 00:07:06,770 So the cloud instance is very basic in terms of its properties, but it easily allows you to add realistic 107 00:07:06,770 --> 00:07:08,720 looking clouds to your game. 108 00:07:08,720 --> 00:07:10,430 I mean, they look pretty stink and cool. 109 00:07:10,430 --> 00:07:16,040 Not gonna lie, these are as realistic clouds as you're going to get in the Roblox game engine.